<?php
/**
 * Description
 *
 * PHP version 7
 *
 * @category Custom
 * @package  Custom
 * @author   ryu <mo5467@126.com>
 * @date     2020-04-29 00:04:48
 * @lastTime 2020-05-01 23:10:45
 * @license  https://opensource.org/licenses/MIT MIT License
 * @link     none
 */
namespace Design\Behavioral\Specification;

class PriceSpecification implements Specification
{

    private $minPrice;

    private $maxPrice;


    public function __construct(?float $minPrice, ?float $maxPrice)
    {
        $this->minPrice = $minPrice;
        $this->maxPrice = $maxPrice;

    }//end __construct()


    public function isSatisfiedBy(Item $item) : bool
    {
        if ($this->minPrice != null && $item->getPrice() < $this->minPrice) {
            return false;
        }

        if ($this->maxPrice != null && $item->getPrice() > $this->maxPrice) {
            return false;
        }

        return true;

    }//end isSatisfiedBy()


}//end class
